<?php
namespace admin\models;

use Yii;
use yii\db\ActiveRecord;
use yii\helpers\Html;
use yii\behaviors\TimestampBehavior;

class AuthItem extends ActiveRecord
{

	public static function tableName()
	{
		return '{{%auth_item}}';
	}

	public function rules()
	{
		return [
			['name', 'unique', 'message' => '{attribute}已存在！'],
			[['name', 'description'], 'required', 'message' => '{attribute}不能为空！'],
			[['name', 'description'], 'trim'],
			['description', 'filter', 'filter' => function ($value) {
				return Html::encode($value);
			}],
			[['type', 'status'], 'number']
		];
	}

	public function attributeLabels()
	{
		return [
			'name' => '角色名称',
			'description' => '角色描述',
			'status' => '状态',
		];
	}

	public function behaviors()
	{
		return [
			[
				'class'      => TimestampBehavior::className(),
				'attributes' => [
					ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
					ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
				],
				// if you're using datetime instead of UNIX timestamp:
				// 'value' => new Expression('NOW()'),
			],
		];
	}

}

?>
        


           
        
 